{% extends "admin/base_site.html" %}
{% load adminmedia admin_list reporting i18n %}

{% block extrastyle %}
  <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" />
{% endblock %}


{% block bodyclass %}change-list{% endblock %}



{% block breadcrumbs %}
<div class="breadcrumbs">
     <a href="/admin/">{% trans "Home" %}</a> &rsaquo;
     <a href="{% url reporting-list %}">Reports</a> &rsaquo;
     {{report.verbose_name}} 

</div>
{% endblock %}



{% block content %}

  <div id="content-main">
    {% block object-tools %}{% endblock %}
    
     {% block date_hierarchy %}{% report_date_hierarchy report %}{% endblock %}
    
    <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">


      {% block filters %}
        {% if report.has_filters %}
		    <div id="changelist-filter">
		      {% if report.detail_list_display %}
		      <h2>Details</h2>
		      <ul><li>{{report.details_switch|safe}}</li></ul>
		      {% endif %}
		      <h2> Group by </h2>
		      <ul>
		      {% for url, name, selected in report.group_by_links %}
		      		<li{% if selected %} class="selected"{% endif %}><a href="{{url}}">{{name}}</a></li>
		      {% endfor %}
		      </ul>
		      <h2>{% trans 'Filter' %}</h2>
		      {% for spec in report.filter_specs %}{% admin_list_filter report spec %}{% endfor %}
		    </div>
		{% endif %}
      {% endblock %}
      

      {% block result_list %}
      <div id="changelist" class="filtered" style="min-width: 800px;">
			<table>
			{% if not report.show_details %}
				<thead>
				<tr>
				{% for head in report.get_headers %}
					<th class="{{head.css_class}}"><a href="{{head.url}}">{{head.text}}</a></th>
				{% endfor %}
				</tr>
				</thead>
			{% endif %}
			{% for row in report.results %}
			{% if not report.show_details %}
				<tr style="width: 600px;" class="row{% if forloop.counter0|divisibleby:"2" %}1{%else%}2{% endif %}">
					{% for value in row.values %}<td>{{value}}</td>{% endfor %}
				</tr>
			{% else%}
				<tr class="row{% if forloop.counter0|divisibleby:"2" %}1{%else%}2{% endif %}">
					<td colspan="{{report.header_count}}" style="text-align: left;"><strong>{{row.values.0}}</strong></td>
				</tr>
			{% endif %}
			{% if row.details %}
				<thead>
				<tr class="row{% if forloop.counter0|divisibleby:"2" %}1{%else%}2{% endif %}">
					<td style="border-bottom: 0px;"></td>
					{% for col in report.get_details_headers %}<th>{{col}}</th>{% endfor %}
				</tr>
				</thead>
				{% for details_row in row.details %}
				<tr class="row{% if forloop.parentloop.counter0|divisibleby:"2" %}1{%else%}2{% endif %}">
					<td style="border-bottom: 0px;"></td>
					{% for value in details_row %}<td>{{value}}</td>{% endfor %}
				</tr>
				{% endfor %}
				{% if report.show_details %}
					<tr class="row{% if forloop.counter0|divisibleby:"2" %}1{%else%}2{% endif %}">
						{% for value in row.values %}
							{% if not forloop.counter0 %}
								<td> </td>
							{% else %}
								<td><strong>{{value}}</strong></td>
							{% endif %}
						{% endfor %}
					</tr>
				{% endif %}

			{% endif %}
			{% endfor %}
			{% if report.aggregate %}
			<tr>
				<td> </td>
				{% for title, value in report.get_aggregation %}
					<td><strong>{{title}}: {{value}}</strong></td>
				{% endfor %}
			</tr>
			{% endif %}
			</table>
	  </div>
      {% endblock %}
      </form>
    </div>
  </div>
{% endblock %}
